<?php 
include("common/conn.php"); 
if($_SESSION['userid']==""){
  echo "<script>window.location.href='login.php';</script>";
}
// 查询服务中心信息
$query = mysql_query("select weixin,tel,qq from xitong where id=1");
$service = mysql_fetch_assoc($query);
// 查询服务中心信息 end

// 更新服务中心信息
if ($_POST) {
  $query = mysql_query("UPDATE xitong SET weixin='".$_POST[weixin]."',tel='".$_POST[tel]."',qq='".$_POST[qq]."' where id=1");
  echo "<script>alert('修改服务中心信息成功!');window.location.href='service.php'</script>";
}
// 更新服务中心信息 end

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <title>e网批发管理后台</title>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <link href="css/styles.css" rel="stylesheet" type="text/css" />
  <link href="css/style2.css" rel="stylesheet" type="text/css" />
</head>

<body>

  <!--header-->
  <?php include("common/header.php");?>
  <!--header end-->


  <!-- staqrt subnav -->
  <div id="sub_nav">

    <div id="subnav_wrap" class="container_12">
      <div id="subnav" class=" grid_12">
        <ul>
          <li><a href="xitong.php">热门搜索</a></li>
          <li><a href="xieyi.php">用户协议</a></li>
          <li><a href="service.php" class="sub_nav_active">服务中心信息</a></li>
          <li><a href="freightRisk.php">海淘运费险</a></li>
          <li><a href="fanquan.php">平台返券</a></li>
          <li><a href="erweima.php">二维码</a></li>
        </ul>

      </div>

    </div>


  </div>
  <div class="container_12">
    <form action="" method="post" class="form" enctype="multipart/form-data"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="30%" scope="col"><label>微信号</label></td>
          <td width="50%" scope="col">
            <input name="weixin" type="text" class="text"  value="<?php echo $service[weixin];?>"/>
          </td>
        </tr>
        <tr>
          <td width="30%" scope="col"><label>电话</label></td>
          <td width="50%" scope="col">
            <input name="tel" type="text" class="text"  value="<?php echo $service[tel];?>"/>
          </td>
        </tr>
        <tr>
          <td width="30%" scope="col"><label>客服QQ</label></td>
          <td width="50%" scope="col">
            <input name="qq" type="text" class="text"  value="<?php echo $service[qq];?>"/>
          </td>
        </tr>
        <tr>
          <td width="40%" scope="col"></td>
          <td width="50%" scope="col">
            <input name="" type="button" value="提交" class="submit" />
          </td>
        </tr>
        </table>

      </form>
    </div>
</body>
<script type="text/javascript">
  // 验证固定电话
  function checkMobile(Mobile) {
    if (!(/^0\d{2,3}-\d{5,9}|0\d{2,3}-\d{5,9}$/.test(Mobile))) {
      return false;
    } else {
      return true;
    }
  }
  // 验证固定电话 end
  // 验证qq号
  function checkQQ(qq) {
    if (!(/^[1-9][0-9]{4,14}$/.test(qq))) {
      return false;
    } else {
      return true;
    }
  }
  // 验证qq号
  $('input[type="button"]').click(function(){
    var tel = $('input[name="tel"]').val();
    var qq = $('input[name="qq"]').val();
    var flag1 = checkMobile(tel);
    var flag2 = checkQQ(qq);
    if (!flag1) {
      alert('固定电话输入有误');
    }else if(!flag2){
      alert('qq输入有误');
    }else{
      $('.form').submit();
    }
  })
</script>
</html>
